﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace BDSim
{
    /// <summary>
    /// 计算日月位置动态库封装
    /// </summary>
    class PlanetEphDLL
    {
        /// <summary>
        /// 计算日月位置动态库初始化
        /// </summary>
        /// <param name="pldata">行星历表数据缓存首地址</param>
        /// <param name="row">数据行数</param>
        /// <param name="col">数据列数</param>
        /// <returns>执行正确返回true，否则返回false</returns>
        [DllImport("PlanetEphDLL.dll", EntryPoint = "PL_Init", CallingConvention = CallingConvention.Cdecl)]
        unsafe public static extern bool PL_Init(double* pldata, int row, int col);

        /// <summary>
        /// 计算日月位置、章动
        /// </summary>
        /// <param name="EphemerisT">历书时</param>
        /// <param name="PlaneFlag">0-->无	 1-->月球, 2-->太阳 ,   3--> 两个都有</param>
        /// <param name="NutationFlag">0-->无	 1-->章动, 2-->天平动,  3--> 两个都有</param>
        /// <param name="Nutations">地心惯性系月球坐标</param>
        /// <param name="Librations">地心惯性系太阳坐标</param>
        /// <param name="PosMoon">章动</param>
        /// <param name="PosSun">平衡动</param>
        /// <returns>小于0表示计算失败，大于等于0表示计算成功</returns>
        [DllImport("PlanetEphDLL.dll", EntryPoint = "PL_POSITION", CallingConvention = CallingConvention.Cdecl)]
        public static extern int PL_POSITION(double EphemerisT,int PlaneFlag,int NutationFlag,double[] Nutations,double[] Librations,double[] PosMoon,double[] PosSun);
    }
}
